JavaScript Ends with
endsWith() returns true if the string finishes with the given characters, false otherwise. It is the mirror of startsWith() and is handy for testing file extensions or suffixes. Case-sensitive.
Syntax
str.endsWith(search) Examples
| Input | Arguments | Output |
|---|---|---|
| "image.png" | ".png" | true |
When to use it
- Validate file extensions.
- Detect trailing markers or units.
Try it live
Type your input and see Ends with transform it instantly.
Want to go further? Chain Ends with with other functions in the visual Playground — pipe one output into the next and watch your data transform.